﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SimpleQueueingSystem.Interfaces;
using SimpleQueueingSystem.Requests.Implementation;

namespace SimpleQueueingSytem.Client
{
    public partial class Form1 : Form
    {
        private int ticketNo;
        public Form1()
        {
            InitializeComponent();
            ticketNo = 0;
            txtQueueName.Text = @".\Private$\SimpleQueue";
        }

        private void btnClaimClick(object sender, EventArgs e)
        {
            try
            {
                ticketNo = ticketNo + 1;
                IRequest claim = new ClaimRequest();
                claim.TicketNo = ticketNo;

                QueueingService.QueueRequest(claim, txtQueueName.Text);
                lblTicketNo.Text = claim.GetTicketInformation();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnChangeOfAddressClick(object sender, EventArgs e)
        {
            try
            {
                ticketNo = ticketNo + 1;
                IRequest claim = new ChangeOfAddressRequest();
                claim.TicketNo = ticketNo;

                QueueingService.QueueRequest(claim, txtQueueName.Text);
                lblTicketNo.Text = claim.GetTicketInformation();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
